<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<script language="JavaScript" type="text/JavaScript">
        function checkNull(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value == "")
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

	function checkForm(){
		return checkNull(true,'id_name','role_name','请输入角色名称');
	}
</script>
<h1>角色管理 - <span id="secondHeading">修改角色信息</span></h1>
<%= form_tag({}, :id=>"input-form") %>
<TABLE border="0" id="INPUT_TABLE">
	<TR><%= form_tag %>
		<td>角色名:</td>
	    <td><input id="role_name" type="text" name="name" value="<%=@role.name%>" maxlength="20" onfocus="checkNull(false,'id_name')" onblur="checkNull(true,'id_name',this.id,'请输入角色名称')")>          <em>*</em><div class="redNsg" id="id_name" style="display:none;"></div></td>
	</tr>
	<tr>
	    <td>所属部门:</td>
	    <td><select name="department_id">
		<% @departments.each do |department| %>
		<option value='<%=department.id%>'
		<%= ' selected' if department.id == @role.department.id %>>
		<%=department.name%> </option>
		<% end %>
			</select>
		</td>
	</tr>
	<tr>
	    <td>备注:</td>
	    <td><textarea cols="50" id="role_memo" name="memo" rows="5"><%=@role.memo%></textarea></td>
	</tr>
	<tr>
	    <td colspan="2" align="right"><input type="submit" value="修改" class="sub" onclick="javascript:return checkForm();"/>&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></td>
	</TR>
</TABLE>
<p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
<%= end_form_tag %>
